﻿
namespace MyLiveMesh.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using System.Web.Security;
    using System.Web.Profile;

    [EnableClientAccess()]
    public class RegistrationDomainService : DomainService
    {
        public void AddUser(Models.RegisterData user)
        {
            MembershipCreateStatus createStatus;
            Membership.CreateUser(user.UserName, user.Password, user.Email, user.SecurityQuestion, user.SecurityAnswer, true, null, out createStatus);

            if (createStatus != MembershipCreateStatus.Success)
            {
                throw new DomainException(createStatus.ToString());
            }

            ProfileBase profile = ProfileBase.Create(user.UserName, true);
            profile.Save();
        }

        public IEnumerable<Models.RegisterData> GetUsers()
        {
            throw new NotSupportedException();
        }
    }
}


